import json

params = {
    "symbol": '123456',
    'type': 'limit',
    'price': 123.4,
    'amount': 23
}

with open("D:\\file\\params.json", 'w') as fout:
    params_str = json.dump(params, fout)

with open("D:\\file\\params.json", 'r') as fin:
    original_params = json.load(fin)

# 将其序列化为json字符串
# params_str = json.dumps(params)
print('after json serialization:{}'.format(params_str))
print('type of params_str = {}, params_str = {}'.format(type(params_str), params))
#  将其反序列化为python的基本数据类型
# original_params = json.loads(params_str)

print('after json deserialization')
print('type of original_params = {}, original_params = {}'.format(type(original_params), original_params))
